<!-- 市级 - 隐患统计 （村级台账）-->
<template>
  <div>
    <div class="header-yhtj">
      <div class="title">
        <div>
          <a-space>
            <span>场所类型2：</span>
            <a-select
              ref="select"
              v-model:value="type_cs"
              style="width: 120px"
              :options="optionsCS"
              @change="handleCsCheck"
            />
          </a-space>
          <a-space>
            <span>隐患类型：</span>
            <a-select
              ref="select"
              v-model:value="type_yh"
              style="width: 120px"
              :options="optionsYH"
              @change="handleYhCheck"
            />
          </a-space>
          <a-space>
            <span>专项类型：</span>
            <a-select
              ref="select"
              v-model:value="type_zx"
              style="width: 120px"
              :options="optionsZH"
              @change="handleZxCheck"
            />
          </a-space>
          <a-space>
            <span>汇总方式：</span>
            <a-select
              ref="select"
              v-model:value="hzfs"
              style="width: 120px"
              :options="optionsHZFS"
              @change="handleHzfsCheck"
            />
          </a-space>
        </div>
        <div class="table-settings">
          <ImportSetting
            :tableData="tableData"
            :tableColumns="currentColumns"
            :wscolsList="wscolsList"
            ref="ImporBusinessDom"
            :excelName="getExcelName()"
            @click="importBusinessFn"
          />
        </div>
      </div>
      <div class="search">
        <div>
          <a-space v-if="type_yh !== '2'">
            <span>开始时间：</span>
            <!-- <a-range-picker v-model:value="dateRange" format="YYYY-MM-DD" />
            <a-button @click="handleClick">获取选中值</a-button>
            <a-button @click="changeTime">更改时间</a-button> -->
            <a-date-picker v-model:value="startDate" :format="dateFormat" />
          </a-space>
          <a-space>
            <span>结束时间：</span>
            <a-date-picker v-model:value="endDate" :format="dateFormat" />
          </a-space>
          <a-space>
            <a-button @click="changeTimeBefore315" style="margin-left: 10px">315前</a-button>
            <a-button @click="changeTimeAfter315">315后</a-button>
          </a-space>
          <a-space class="search-btn">
            <a-button type="primary" v-if="isShowBackBtn()" @click="goBack">返回</a-button>
            <a-button type="primary" @click="searchBtn">查询</a-button>
          </a-space>
        </div>
      </div>
    </div>
    <a-table
      :dataSource="tableData"
      :columns="currentColumns"
      :pagination="false"
      bordered
      :scroll="{ x: 2300, y: tableHeight }"
      :loading="loading"
    >
      <!-- vue3 中的写法 -->
      <template #headerCell="{ column }">
        <template v-if="column.key === 'use_electric_bicycle'">
          <Tooltip placement="top">
            <template #title>
              <span
                >电动自行车、电动平衡车及其蓄电池在房屋公共区域、疏散走道、楼梯间、安全出口或房间内停放、充电</span
              >
            </template>
            <span> 电动自行... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_bottled_liquefied_gas'">
          <Tooltip placement="top">
            <template #title>
              <span>出租房屋的公共区域、租住房间内、地下室、半地下室使用瓶装液化石油气</span>
            </template>
            <span> 出租房屋... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_stacked_items'">
          <Tooltip placement="top">
            <template #title>
              <span>疏散走道、楼梯间、安全出口处堆放物品影响人员疏散</span>
            </template>
            <span> 疏散走道... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_burglar_mesh'">
          <Tooltip placement="top">
            <template #title>
              <span>外窗、疏散走道安装防盗网、广告牌、铁栅栏等影响逃生和灭火救援的障碍物</span>
            </template>
            <span> 外窗、疏... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_ceiling'">
          <Tooltip placement="top">
            <template #title>
              <span>供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚等</span>
              <!-- <span>导出</span> -->
            </template>
            <span>供人员疏... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'is_completely_isolated'">
          <Tooltip placement="top">
            <template #title>
              <span
                >居住区域与生产、经营、存储区域未使用实体砖墙、防火门等进行完全分隔，同时居住区域未设置直通室外的独立疏散楼梯、安全出口</span
              >
              <!-- <span>导出</span> -->
            </template>
            <span>居住区域... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_flammable_materials'">
          <Tooltip placement="top">
            <template #title>
              <span
                >屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建，疏散通道使用易燃可燃材料装修</span
              >
              <!-- <span>导出</span> -->
            </template>
            <span>屋顶、围... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'unauthorized_electrical_connect'">
          <Tooltip placement="top">
            <template #title>
              <span>在供电设施上擅自接线用电，擅自在导线上接用电器设备</span>
            </template>
            <span>在供电设... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'charging_facilities_no_standard'">
          <Tooltip placement="top">
            <template #title>
              <span
                >电动自行车集中充电设施未按照农村地区电动自行车集中充电设施建设指引要求建设或整改
              </span>
            </template>
            <span>电动自行... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'not_enough_exits'">
          <Tooltip placement="top">
            <template #title>
              <span>出租房屋3层及以上出租住人，且不满足2部疏散楼梯和首层2个安全出口</span>
            </template>
            <span>出租房屋... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_flammable_insulation_materials'">
          <Tooltip placement="top">
            <template #title>
              <span
                >采用易燃可燃保温材料的冷库、设置液氮制冷剂的冷库的自建房设置居住场所（栋）</span
              >
            </template>
            <span>采用易燃... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'use_flammable_dangerous_goods'">
          <Tooltip placement="top">
            <template #title>
              <span>生产、储存、经营易燃易爆危险品的自建房设置居住场所（栋）</span>
            </template>
            <span>生产、储... </span>
          </Tooltip>
        </template>
        <template v-if="column.key === 'above_three_floor_self'">
          <Tooltip placement="top">
            <template #title>
              <span>3层及3层以上建筑是否仅房主自住使用</span>
            </template>
            <span>3层及3... </span>
          </Tooltip>
        </template>
        <!-- 商业 -->
        <template v-if="column.key === 'fire_service_damaged'">
          <Tooltip placement="top">
            <template #title>
              <span>建筑消防设施严重损坏</span>
            </template>
            <span>建筑消防... </span>
          </Tooltip>
        </template>
        <template
          v-if="
            // (data.type_cs === '3' || data.type_cs === '1') &&
            column.key === 'use_store_dangerous_goods'
          "
        >
          <Tooltip placement="top">
            <template #title>
              <span>人员密集场所违规使用、储存易燃易爆危险品</span>
            </template>
            <span>人员密集... </span>
          </Tooltip>
        </template>
        <template
          v-if="
            // (data.type_cs === '3' || data.type_cs === '1') &&
            column.key === 'threaten_safety_fire_hazards'
          "
        >
          <Tooltip placement="top">
            <template #title>
              <span>其他可能严重威胁公共安全的火灾隐患</span>
            </template>
            <span>其他可能... </span>
          </Tooltip>
        </template>
      </template>

      <!-- 列和 -->
      <!-- <template #summary>
        <a-table-summary-row>
          <a-table-summary-cell>
            <Tooltip placement="top">
              <template #title>
                <span>汇总</span>
              </template>
              <span>Total </span>
            </Tooltip>
          </a-table-summary-cell>
          <a-table-summary-cell v-for="(item, index) in tableColumns.length - 1" :key="index">
            <a-typography-text type="danger">1111</a-typography-text>
          </a-table-summary-cell>
        </a-table-summary-row>
      </template> -->
    </a-table>
    <Detail
      v-model:visible="visible"
      title="抽屉标题"
      :width="1000"
      :detailTableHeight="detailTableHeight"
      :closable="true"
      :destroyOnClose="true"
      :data="detailData"
      :detailParams="detailParams"
      :hzfs="hzfs"
      :currentXzqdmname="currentXzqdmname"
      :currentTitle="currentTitle"
      @close="handleClose"
    >
      <!-- <p>抽屉内容</p> -->
    </Detail>
  </div>
</template>
<script lang="ts" setup>
  // import moment, { Moment } from 'moment';
  import moment from 'moment';
  import dayjs from 'dayjs';
  import { ref, reactive, toRefs, onMounted, onBeforeMount, computed, nextTick } from 'vue';
  import { Tooltip, message } from 'ant-design-vue';
  import ImportSetting from '/@/views/village/housesDangerBusiness/ImportSetting.vue';
  import Detail from './component/detail.vue';
  import {
    getLivingList,
    getFireDangerList, // 按 隐患
    getLouDangerList, // 按 楼栋
    getFireDangerDetailList, // 按隐患
    getFireLouDetailList, // 按楼栋
  } from '/@/api/demo/system';
  import { iTableData, iTableColumns } from './types/table';
  import { iParams } from './types/params';

  import { useUserStore } from '/@/store/modules/user';

  // import { t } from '/@/hooks/web/useI18n';
  // 转义地区编码
  // import { selectClassFlyDict } from '/@/dict/bj_dict';
  const visible = ref(false);
  let detailData = ref<any[]>([]);
  let detailParams = ref({}); // 详情参数
  let detailTableHeight = ref<number>(0); // 表格高度
  let tableHeight = ref<number>(0); // 表格高度
  const dateFormat = 'YYYY-MM-DD';
  // const value1 = ref<any>(moment('2015/01/01', dateFormat));
  // const dateRange1 = ref<[momentType] | null>(null);
  const startDate = ref<any>(null); // 开始时间
  const endDate = ref<any>(null); // 结束时间

  // let dangerType = ref<string>('1'); // 隐患类型
  // const value2 = ref<string>('777'); // 存储专项的值
  // const dateRange = ref<[Date, Date] | null>(null);
  // const dateRange = ref<[momentType, momentType] | null>(null);
  // type momentType = {
  //   $d: Date;
  //   $M: number;
  // };
  // 场所类型
  const optionsCS = ref<any[]>([
    {
      value: '3',
      label: '全部',
    },
    {
      value: '0',
      label: '居住',
    },
    {
      value: '1',
      label: '商业',
    },
  ]);
  // 隐患类型
  const optionsYH = ref<any[]>([
    {
      value: '0',
      label: '发现隐患',
    },
    {
      value: '1',
      label: '消隐隐患',
    },
    {
      value: '2',
      label: '剩余隐患',
    },
  ]);
  // 专项类型
  const optionsZH = ref<any[]>([
    // {
    //   value: '0',
    //   label: '全部',
    // },
    {
      value: '777',
      label: '777村',
    },
    {
      value: '108',
      label: '108村',
    },
  ]);
  // 汇总方式
  const optionsHZFS = ref<any[]>([
    {
      value: '1',
      label: '隐患',
    },
    {
      value: '2',
      label: '楼栋',
    },
  ]);
  let userInfo = ref<any>(null);
  let currentColumns = ref<any>([]);
  let data = reactive<{
    tableData: iTableData[];
    tableColumns: iTableColumns[];
    wscolsList: { wch: number }[];
    id: number | any;
    loading: Boolean;
    keyWorld: String;
    cityToken: string | any;
    startTime: string; // 开始时间
    endTime: string; // 结束时间
    type_cs: string; // 场所类型
    type_yh: string; // 隐患类型
    type_zx: string; // 专项类型
    hzfs: string; // 汇总方式
    jdCode: string; // 街道code
    qxCode: string; // 区县
    groupbyLever: string; // 0区县,1街镇,2村级
    groupbyLever_code: string; // 当前行等级编码
    currentXzqdmname: string; // 当前行政区名称
    currentTitle: string;
  }>({
    // 表格数据
    tableData: [],
    tableColumns: [
      {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
        align: 'center',
        width: 100,
        fixed: 'left',
      },
      {
        title: '区县名称',
        dataIndex: 'xzqdmname',
        key: 'xzqdmname',
        align: 'center',
        width: 100,
        customCell: (row, index, column) => {
          // console.log('@index ', index);
          // console.log('@row ', row);
          // console.log('@column ', column);
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: () => {
          //     // console.log('@row==', row);
          //     if (isNoHzyh) {
          //       data.groupbyLever = '1';
          //       data.qxCode = row.xzqdm; // 保存 东城区
          //       data.groupbyLever_code = row.xzqdm;
          //       data.loading = true;
          //       getData();
          //     }
          //   },
          // };
        },
      },
      {
        title: '街镇 名称',
        dataIndex: 'townname',
        key: 'townname',
        align: 'center',
        width: 170,
        customCell: (row, index, column) => {
          // console.log('@index ', index);
          // console.log('@row ', row);
          // console.log('@column ', column);
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: () => {
          //     if (isNoHzyh) {
          //       data.groupbyLever = '2';
          //       data.jdCode = row.xzqdm;
          //       data.groupbyLever_code = row.xzqdm;
          //       // console.log('@jdCode', data.jdCode);
          //       // console.log('@groupbyLever_code', data.groupbyLever_code);
          //       data.loading = true;
          //       getData();
          //     }
          //   },
          // };
        },
      },
      {
        title: '村庄 名称',
        dataIndex: 'villagename',
        key: 'villagename',
        align: 'center',
        width: 170,
      },
      // 居住 商业
      {
        title: '房屋(栋)2',
        dataIndex: 'ypc_sl',
        key: 'ypc_sl',
        align: 'center',
        width: 120,
        // customCell: (row, index, column) => {
        //   let isNoHzyh =
        //     row.townname !== '汇总' ||
        //     row.villagename !== '汇总' ||
        //     row.xzqdmname !== '汇总'
        //       ? true
        //       : false;
        //   let style = 'cursor:pointer;text-decoration: underline; color: blue;';
        //   return {
        //     children: row.xzqdmname,
        //     style: `${isNoHzyh === true ? style : ''}`,
        //     class: 'cell-hover',
        //     onClick: async () => {
        //       if (isNoHzyh) {
        //         getDetailData(row, column);
        //         if (detailData.value) {
        //           data.currentXzqdmname = row.xzqdmname;
        //           data.currentTitle = column.__originColumn__.title;
        //           loading.value = false;
        //           showDrawer();
        //         }
        //       }
        //     },
        //   };
        // },
      },
      {
        title: '采用易燃可燃保温材料的冷库、设置液氮制冷剂的冷库的自建房设置居住场所（栋）',
        dataIndex: 'use_flammable_insulation_materials',
        key: 'use_flammable_insulation_materials',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // console.log('@index ', index);
          // console.log('@row ', row);
          // console.log('@column ', column);
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //     // if (isNoHzyh) {
          //     //   let params: iParams = {
          //     //     type_zx: data.type_zx,
          //     //     type_cs: data.type_cs,
          //     //     type_yh: data.type_yh,
          //     //     groupbyLever: data.groupbyLever,
          //     //     startTime: data.startTime + ' 00:00:00',
          //     //     endTime: data.endTime + ' 23:59:59',
          //     //     // xzqdm: row.xzqdm,
          //     //     groupbyLever_code: row.xzqdm,
          //     //     groupbyLever_code_project: column.key,
          //     //   };
          //     //   loading.value = true;
          //     //   let res: any = await getFireDangerDetailList(params);
          //     //   loading.value = false;
          //     //   res.forEach((item, index) => {
          //     //     item.index = ++index;
          //     //     // console.log('@item==', item);
          //     //   });
          //     //   detailData.value = res;
          //     //   if (detailData.value.length > 0) {
          //     //     data.currentXzqdmname = row.xzqdmname;
          //     //     data.currentTitle = column.__originColumn__.title;
          //     //     loading.value = false;
          //     //     showDrawer();
          //     //   } else {
          //     //     message.info('该配置项没有数据');
          //     //   }
          //     // }
          //   },
          // };
        },
      },
      // 居住 商业
      {
        title: '生产、储存、经营易燃易爆危险品的自建房设置居住场所（栋）',
        dataIndex: 'use_flammable_dangerous_goods',
        key: 'use_flammable_dangerous_goods',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      // 居住 商业
      {
        title: '3层及3层以上建筑是否仅房主自住使用',
        dataIndex: 'above_three_floor_self',
        key: 'above_three_floor_self',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },

      //  商业
      {
        title:
          '电动自行车、电动平衡车及其蓄电池在房屋公共区域、疏散走道、楼梯间、安全出口或房间内停放、充电',
        dataIndex: 'use_electric_bicycle',
        key: 'use_electric_bicycle',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '出租房屋的公共区域、租住房间内、地下室、半地下室使用瓶装液化石油气',
        dataIndex: 'use_bottled_liquefied_gas',
        key: 'use_bottled_liquefied_gas',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '疏散走道、楼梯间、安全出口处堆放物品影响人员疏散',
        dataIndex: 'use_stacked_items',
        key: 'use_stacked_items',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },

      {
        title: '外窗、疏散走道安装防盗网、广告牌、铁栅栏等影响逃生和灭火救援的障碍物',
        dataIndex: 'use_burglar_mesh',
        key: 'use_burglar_mesh',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚等',
        dataIndex: 'use_ceiling',
        key: 'use_ceiling',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title:
          '居住区域与生产、经营、存储区域未使用实体砖墙、防火门等进行完全分隔，同时居住区域未设置直通室外的独立疏散楼梯、安全出口',
        dataIndex: 'is_completely_isolated',
        key: 'is_completely_isolated',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建，疏散通道使用易燃可燃材料装修',
        dataIndex: 'use_flammable_materials',
        key: 'use_flammable_materials',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '在供电设施上擅自接线用电，擅自在导线上接用电器设备',
        dataIndex: 'unauthorized_electrical_connect',
        key: 'unauthorized_electrical_connect',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      // 商业
      {
        title: '出租房屋3层及以上出租住人，且不满足2部疏散楼梯和首层2个安全出口',
        dataIndex: 'not_enough_exits',
        key: 'not_enough_exits',
        align: 'center',
        // width: 170,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '建筑消防设施严重损坏',
        dataIndex: 'fire_service_damaged',
        key: 'fire_service_damaged',
        align: 'center',
        // width: 170,
        // show: false,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '人员密集场所违规使用、储存易燃易爆危险品',
        dataIndex: 'use_store_dangerous_goods',
        key: 'use_store_dangerous_goods',
        align: 'center',
        // width: 170,
        // show: false,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },
      {
        title: '其他可能严重威胁公共安全的火灾隐患',
        dataIndex: 'threaten_safety_fire_hazards',
        key: 'threaten_safety_fire_hazards',
        align: 'center',
        // width: 170,
        // isShow: false,
        customCell: (row, index, column) => {
          // let isNoHzyh =
          //   row.townname !== '汇总' || row.villagename !== '汇总' || row.xzqdmname !== '汇总'
          //     ? true
          //     : false;
          // let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          // let isNoZero = row[column.key] !== 0 ? true : false;
          // return {
          //   children: row.xzqdmname,
          //   style: `${isNoHzyh === true && isNoZero ? style : ''}`,
          //   class: 'cell-hover',
          //   onClick: async () => {
          //     getDetailData(row, index, column, isNoHzyh, isNoZero);
          //   },
          // };
        },
      },

      // {
      //   title: '电动自行车集中充电设施未按照农村地区电动自行车集中充电设施建设指引要求建设或整改',
      //   dataIndex: 'charging_facilities_no_standard',
      //   key: 'charging_facilities_no_standard',
      //   align: 'center',
      //   // width: 170,
      // },

      {
        title: '合计',
        dataIndex: 'sumall',
        key: 'sumall',
        align: 'center',
        width: 100,
        fixed: 'right',
      },
    ],
    id: null,
    loading: false,
    keyWorld: '',
    startTime: '2023-03-16 00:00:00', // 开始时间
    endTime: '2043-03-16 00:00:00', // 结束时间
    type_cs: '3', // 场所类型 居住0商业1  全部 3
    type_yh: '0', // 隐患类型  0发现隐患 1消隐 2剩余
    type_zx: '777', // 专项类型 108,777,0(全部)
    hzfs: '2', // 汇总方式 （1.隐患 2.楼栋）
    groupbyLever: '0', // 0区县,1街镇,2村级
    groupbyLever_code: '',
    currentXzqdmname: '', // 当前行政区名称
    currentTitle: '', // 当前详情标题
    jdCode: '', // 街道code
    qxCode: '', // 区县code
    cityToken: '', // 判断是不是市区 110000 是北京市 展示搜索宽
    wscolsList: [{ wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }],
  });
  // 表格的 ref Dom名称
  const ImporBusinessDom: any = ref(null);
  let {
    tableData,
    tableColumns,
    loading,
    wscolsList,
    type_cs,
    type_yh,
    type_zx,
    hzfs,
    groupbyLever,
    currentXzqdmname,
    currentTitle,
  } = toRefs(data);
  function handleCsCheck(value: string) {
    data.type_cs = value;
    // console.log('场所回调', data.type_cs);
  }
  function handleYhCheck(value: string) {
    data.type_yh = value;
    // console.log('专项回调', data.type_yh);
  }
  function handleZxCheck(value: string) {
    data.type_zx = value;
    // console.log('场所回调', data.type_zx);
  }
  function handleHzfsCheck(value: string) {
    data.hzfs = value;
    // console.log('场所回调', data.type_zx);
  }
  // 时间组件的点击回调
  // function handleClick() {
  //   if (dateRange.value) {
  //     const [startDate, endDate] = dateRange.value;
  //     data.startTime = moment(startDate.$d).format('YYYY-MM-DD HH:mm:ss');
  //     data.endTime = moment(endDate.$d).format('YYYY-MM-DD HH:mm:ss');
  //     console.log('选中的起始日期：', data.startTime);
  //     console.log('选中的结束日期：', data.endTime);
  //   }
  // }
  // 改变时间后的回调
  // function changeTime() {
  //   const start: any = dayjs('2023-04-21 19:30:00');
  //   const end: any = dayjs('2023-04-28 19:30:00');
  //   dateRange.value = [start, end];
  //   handleClick();
  // }

  // 给时间组件重新赋值
  // 315 前
  function changeTimeBefore315() {
    const start: any = dayjs('2022-01-01');
    const end: any = dayjs('2023-03-15');
    startDate.value = start;
    endDate.value = end;
    getTime();
  }
  // 315后
  function changeTimeAfter315() {
    let time1: any = new Date().getTime();
    var date = new Date(time1);
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    var strDate = Y + M + D;
    const start: any = dayjs('2023-03-16');
    const end: any = dayjs(`${strDate}`);
    startDate.value = start;
    endDate.value = end;
    getTime();
  }
  function getTime() {
    data.startTime = moment(startDate.value.$d).format('YYYY-MM-DD');
    data.endTime = moment(endDate.value.$d).format('YYYY-MM-DD');
    // console.log('@查询参数 -- 开始时间', data.startTime);
    // console.log('@查询参数 -- 结束时间', data.endTime);
  }
  function searchBtn() {
    // getExcelName();
    // console.log('@tableColumns', tableColumns.value);
    getTime();
    data.loading = true;
    getData();
  }
  // 打开抽屉
  function showDrawer() {
    visible.value = !visible.value;
  }
  function handleClose() {
    visible.value = !visible.value;
  }

  function goBack() {
    // console.log('返回', data.groupbyLever);
    const { role, district } = userInfo.value;
    data.loading = true;
    if (data.groupbyLever === '1') {
      // console.log('街道code', data.jdCode);
      // console.log('区县code ', data.qxCode);
      data.groupbyLever = '0';
      data.groupbyLever_code = '';
      getData();
    } else if (data.groupbyLever === '2') {
      // console.log('街道code22', data.jdCode);
      // console.log('区县code22 ', data.qxCode);
      data.groupbyLever = '1';
      if (role === 'City') {
        data.groupbyLever_code = data.qxCode;
      } else if (role === 'Area') {
        data.groupbyLever_code = district.regionCode;
      }
      //  else if (role === 'Street') {
      //   data.groupbyLever_code = district.regionCode;
      // }
      getData();
    }
  }
  function isShowBackBtn() {
    const { role, district } = userInfo.value;
    // groupbyLever !== '0'
    let isShow = false;
    if (role === 'City') {
      if (data.groupbyLever !== '0') {
        isShow = true;
      }
    } else if (role === 'Area') {
      if (data.groupbyLever !== '0' && data.groupbyLever !== '1') {
        isShow = true;
      }
    } else if (role === 'Street') {
      isShow = false;
    }
    return isShow;
  }

  function getExcelName() {
    /*******************************************/
    let zxName = '全部村';
    if (data.type_zx === '108') {
      zxName = '108村';
    } else if (data.type_zx === '777') {
      zxName = '777村';
    } else if (data.type_zx === '0') {
      zxName = '全部村';
    }
    let csName = '全部场所';
    if (data.type_cs === '0') {
      csName = '居住';
    } else if (data.type_cs === '1') {
      csName = '商业';
    } else if (data.type_cs === '3') {
      csName = '全部场所';
    }
    let yhName = '发现隐患';
    if (data.type_yh === '0') {
      yhName = '发现隐患';
    } else if (data.type_yh === '1') {
      yhName = '消隐';
    } else if (data.type_yh === '3') {
      yhName = '剩余';
    }
    let time1: any = new Date().getTime();
    var date = new Date(time1);
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';

    // var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    // var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    // var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    // var strDate = Y + M + D + h + m + s;
    var strDate = Y + M + D;
    // let Date = Date.new();
    return `${zxName}_ ${csName}_${yhName}_${strDate}`;
    // console.log('场所名称', csName);
    // // console.log('场所类型', data.type_yh);
    // console.log('专项名称', zxName);
    // console.log('隐患名称', yhName);
  }
  // 获取详情的数据
  // async function getDetailData(row: any, column: any) {
  //   let params: iParams = {
  //     type_zx: data.type_zx,
  //     type_cs: data.type_cs,
  //     type_yh: data.type_yh,
  //     groupbyLever: data.groupbyLever,
  //     startTime: data.startTime + ' 00:00:00',
  //     endTime: data.endTime + ' 23:59:59',
  //     // xzqdm: row.xzqdm,
  //     groupbyLever_code: row.xzqdm,
  //     groupbyLever_code_project: column.key,
  //   };
  //   loading.value = true;
  //   let res: any = await getFireDangerDetailList(params);
  //   res.forEach((item, index) => {
  //     item.index = ++index;
  //     // console.log('@item==', item);
  //   });
  //   detailData.value = res;
  // }
  const getDetailData = async (
    row: any,
    index: number,
    column: any,
    isNoHzyh: boolean,
    isNoZero: boolean,
  ) => {
    if (isNoHzyh && isNoZero) {
      let params: iParams = {
        type_zx: data.type_zx,
        type_cs: data.type_cs,
        type_yh: data.type_yh,
        groupbyLever: data.groupbyLever,
        startTime: data.startTime + ' 00:00:00',
        endTime: data.endTime + ' 23:59:59',
        groupbyLever_code: row.xzqdm,
        groupbyLever_code_project: column.key,
      };

      detailParams.value = params;
      data.currentTitle = column.__originColumn__.title;
      showDrawer();
      // loading.value = true;
      // let res: any = {};
      // if (data.hzfs === '1') {
      //   res = await getFireDangerDetailList(params);
      // } else {
      //   res = await getFireLouDetailList(params);
      // }

      // if (res) {
      //   loading.value = false;
      //   res.forEach((item, index) => {
      //     item.index = ++index;
      //   });
      //   detailData.value = res;
      //   if (detailData.value.length > 0) {
      //     data.currentXzqdmname = row.xzqdmname;
      //     data.currentTitle = column.__originColumn__.title;
      //     loading.value = false;
      //     showDrawer();
      //   } else {
      //     message.info('该配置项没有数据');
      //   }
      // }
    }
  };
  function setInitParams() {
    const { role, district } = userInfo.value;
    if (role === 'City') {
      data.groupbyLever = '0';
      data.groupbyLever_code = ''; //
    } else if (role === 'Area') {
      data.groupbyLever = '1';
      data.groupbyLever_code = district.regionCode; // 当前区县
    } else if (role === 'Street') {
      data.groupbyLever = '2';
      data.groupbyLever_code = district.regionCode; // 当前街道
    }
  }
  async function getData() {
    // const { role } = userInfo.value;
    // console.log('@useUserStore==用户信息--role', role);
    // 北京市 的数据
    getCurrentColumns();

    let params: iParams = {
      type_zx: data.type_zx,
      type_cs: data.type_cs,
      type_yh: data.type_yh,
      hzfs: data.hzfs,
      groupbyLever: '2',
      // groupbyLever_code: data.groupbyLever_code,
      startTime: data.startTime + ' 00:00:00',
      endTime: data.endTime + ' 23:59:59',
    };
    // console.log('@市级参数', params);
    // getBusinessList,
    // getLivingList,
    loading.value = true;
    // let res: any = await getLivingList(params);
    let res: any = [];
    if (data.hzfs === '1') {
      res = await getFireDangerList(params);
    } else {
      res = await getLouDangerList(params);
      // console.log('@res====楼栋', res);
    }
    // console.log('@res', res);
    // console.log('@res--(居住)系统汇总表', res);
    if (res && res.length > 0) {
      loading.value = false;
      res.forEach((item: any, index: number) => {
        // item.name = selectClassFlyDict(item.xzqdm);
        item.index = index + 1;
        // console.log('@bicycle', item.use_electric_bicycle);
      });
      // 算列和
      let above_three_floor_self_count = total(res, 'above_three_floor_self');
      let charging_facilities_no_count = total(res, 'charging_facilities_no_standard');
      let index_count = res.length + 1;
      let is_completely_isolated_count = total(res, 'is_completely_isolated');
      let not_enough_exits_count = total(res, 'not_enough_exits');
      let sumall_count = total(res, 'sumall');
      let unauthorized_electrical_connect_count = total(res, 'unauthorized_electrical_connect');
      let use_bottled_liquefied_gas_count = total(res, 'use_bottled_liquefied_gas');
      let use_burglar_mesh_count = total(res, 'use_burglar_mesh');
      let use_ceiling_count = total(res, 'use_ceiling');
      let use_electric_bicycle_count = total(res, 'use_electric_bicycle');
      let use_flammable_dangerous_goods_count = total(res, 'use_flammable_dangerous_goods');
      let use_flammable_insulation_materials_count = total(
        res,
        'use_flammable_insulation_materials',
      );
      let use_flammable_materials_count = total(res, 'use_flammable_materials');
      let use_stacked_items_count = total(res, 'use_stacked_items');
      let ypc_sl_count = total(res, 'ypc_sl');
      // 商业
      let fire_service_damaged_count = total(res, 'fire_service_damaged');
      let use_store_dangerous_goods_count = total(res, 'use_store_dangerous_goods');
      let threaten_safety_fire_hazards_count = total(res, 'threaten_safety_fire_hazards');
      // console.log('@fire_service_damaged_count', fire_service_damaged_count);
      // console.log('@use_store_dangerous_goods_count', use_store_dangerous_goods_count);
      // console.log('@threaten_safety_fire_hazards_count', threaten_safety_fire_hazards_count);
      let allObj = {
        above_three_floor_self: above_three_floor_self_count,
        charging_facilities_no_standard: charging_facilities_no_count,
        index: index_count,
        is_completely_isolated: is_completely_isolated_count,
        not_enough_exits: not_enough_exits_count,
        xzqdmname: '汇总',
        townname: '汇总',
        villagename: '汇总',
        sumall: sumall_count,
        unauthorized_electrical_connect: unauthorized_electrical_connect_count,
        use_bottled_liquefied_gas: use_bottled_liquefied_gas_count,
        use_burglar_mesh: use_burglar_mesh_count,
        use_ceiling: use_ceiling_count,
        use_electric_bicycle: use_electric_bicycle_count,
        use_flammable_dangerous_goods: use_flammable_dangerous_goods_count,
        use_flammable_insulation_materials: use_flammable_insulation_materials_count,
        use_flammable_materials: use_flammable_materials_count,
        use_stacked_items: use_stacked_items_count,
        // 商业
        fire_service_damaged: fire_service_damaged_count,
        use_store_dangerous_goods: use_store_dangerous_goods_count,
        threaten_safety_fire_hazards: threaten_safety_fire_hazards_count,
        ypc_sl: ypc_sl_count,
      };
      // console.log('data', data);
      data.tableData = [...res, allObj];
    }
  }

  // 计算总数的方法
  function total(arr: any, item: any) {
    let total = arr.reduce((pre: any, cur: any) => {
      return pre + cur[item];
    }, 0);
    return total;
  }
  function importBusinessFn() {
    if (ImporBusinessDom.value) {
      ImporBusinessDom.value.importFn();
    }
  }
  function getUserInfo() {
    const userStore = useUserStore();
    userInfo.value = userStore?.getUserInfo;
  }
  // 获取当前列
  function getCurrentColumns() {
    const { role, district } = userInfo.value;
    // console.log('@district', district);
    // console.log('@role', role);
    // data.groupbyLever_code = district.id;
    // let arr: any[] = [];
    if (role === 'City') {
      // 市级账号
      if (data.hzfs === '2') {
        currentColumns.value = data.tableColumns.filter((item) => item.key !== 'sumall');
      } else {
        currentColumns.value = data.tableColumns;
      }

      // console.log('@市级');
      if (data.type_cs === '0') {
        // 居住的判断
        // groupbyLever: string; // 0区县,1街镇,2村级
        if (data.groupbyLever === '0') {
          // 0区县
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'villagename' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'villagename' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards',
            );
          }
        } else if (data.groupbyLever === '1') {
          // 1街镇
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards',
            );
          }
        } else if (data.groupbyLever === '2') {
          // 2村级
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards',
            );
          }
        }
      } else {
        // 商业 、全部
        // groupbyLever: string; // 0区县,1街镇,2村级
        if (data.groupbyLever === '0') {
          // 0区县
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' && item.key !== 'villagename' &&
                item.key !== 'sumall',
            );
          } else {
            // currentColumns.value = data.tableColumns.filter(
            //   (item) => item.key !== 'townname' && item.key !== 'villagename',
            // );
          }
        } else if (data.groupbyLever === '1') {
          // 1街镇
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' && item.key !== 'xzqdmname' &&
                item.key !== 'sumall',
            );
          } else {
            // currentColumns.value = data.tableColumns.filter(
            //   (item) => item.key !== 'villagename' && item.key !== 'xzqdmname',
            // );
          }
        } else if (data.groupbyLever === '2') {
          // 2村级
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' && item.key !== 'xzqdmname' &&
                item.key !== 'sumall',
            );
          } else {
            // currentColumns.value = data.tableColumns.filter(
            //   (item) => item.key !== 'townname' && item.key !== 'xzqdmname',
            // );
          }
        }
      }
    } else if (role === 'Area') {
      // 区县账号
      if (data.hzfs === '2') {
        currentColumns.value = data.tableColumns.filter(
          (item) =>
            //  item.key !== 'villagename' && item.key !== 'xzqdmname' &&
            item.key !== 'sumall',
        );
      } else {
        // currentColumns.value = data.tableColumns.filter(
        //   (item) => item.key !== 'villagename' && item.key !== 'xzqdmname',
        // );
      }

      // 居住
      if (data.type_cs === '0') {
        if (data.groupbyLever === '1') {
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards',
            );
          }
        } else if (data.groupbyLever === '2') {
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' &&
                // item.key !== 'xzqdmname' &&
                item.key !== 'fire_service_damaged' &&
                item.key !== 'use_store_dangerous_goods' &&
                item.key !== 'threaten_safety_fire_hazards',
            );
          }
        }
      } else {
        if (data.groupbyLever === '1') {
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'villagename' && item.key !== 'xzqdmname' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns;
          }
        } else if (data.groupbyLever === '2') {
          if (data.hzfs === '2') {
            currentColumns.value = data.tableColumns.filter(
              (item) =>
                // item.key !== 'townname' && item.key !== 'xzqdmname' &&
                item.key !== 'sumall',
            );
          } else {
            currentColumns.value = data.tableColumns;
          }
        }
      }
    } else if (role === 'Street') {
      // 街道账号
      if (data.hzfs === '2') {
        currentColumns.value = data.tableColumns.filter(
          (item) =>
            //item.key !== 'townname' && item.key !== 'xzqdmname' &&
            item.key !== 'sumall',
        );
      } else {
        currentColumns.value = data.tableColumns;
      }

      // 居住
      if (data.type_cs === '0') {
        if (data.hzfs === '2') {
          currentColumns.value = data.tableColumns.filter(
            (item) =>
              // item.key !== 'townname' &&
              // item.key !== 'xzqdmname' &&
              item.key !== 'fire_service_damaged' &&
              item.key !== 'use_store_dangerous_goods' &&
              item.key !== 'threaten_safety_fire_hazards' &&
              item.key !== 'sumall',
          );
        } else {
          currentColumns.value = data.tableColumns.filter(
            (item) =>
              // item.key !== 'townname' &&
              // item.key !== 'xzqdmname' &&
              item.key !== 'fire_service_damaged' &&
              item.key !== 'use_store_dangerous_goods' &&
              item.key !== 'threaten_safety_fire_hazards',
          );
        }
      } else {
        if (data.hzfs === '2') {
          currentColumns.value = data.tableColumns.filter(
            (item) =>
              // item.key !== 'townname' && item.key !== 'xzqdmname' &&
              item.key !== 'sumall',
          );
        } else {
          currentColumns.value = data.tableColumns;
        }
      }
    }
  }
  const getTableHeight = () => {
    setTimeout(() => {
      let a: any = document.querySelector('.search');
      let b: any = document.querySelector('.title');
      let c: any = document.querySelector('.ant-layout-header');
      let d: any = document.querySelector('.ant-table-thead');
      // console.log('@search -a', a.offsetHeight);
      // console.log('@search -b', b.offsetHeight);
      // console.log('@search -c', c.offsetHeight);
      // console.log('@search -c', d.offsetHeight);
      let oHeight = a.offsetHeight + b.offsetHeight + c.offsetHeight + d.offsetHeight;
      detailTableHeight.value = window.innerHeight - 185;
      tableHeight.value = window.innerHeight - oHeight;
      // console.log(`表格高度`, tableHeight.value);
    });
  };
  // let displayColumns: any = computed(() => {});

  onBeforeMount(() => {
    getUserInfo();
  });
  onMounted(() => {
    changeTimeAfter315();
    setInitParams();
    getData();
    getTableHeight();
  });
</script>

<style lang="less">
  .header-yhtj {
    width: 100%;
    // height: 250px;
    display: flex;
    // border: 1px solid red;
    line-height: 40px;
    justify-content: space-between;
    flex-direction: column;
    .title {
      display: flex;
      justify-content: space-between;
    }
    .search {
      // border: 1px solid green;
      height: 40px;
      position: relative;
      .search-btn {
        position: absolute;
        right: 0;
        top: 2px;
        margin-right: 12px;
      }
    }
    .table-settings {
      & > * {
        margin-right: 12px;
      }

      svg {
        width: 2em;
        height: 2em;
      }
    }
  }
  .cell-hover:hover {
    background-color: #df0909;
  }
</style>
